import prompt from '@blueos.window.prompt'

/**
 * 拼接 url 和参数
 */
function queryString(url, query) {
  let str = []
  for (let key in query) {
    str.push(key + '=' + query[key])
  }
  let paramStr = str.join('&')
  return paramStr ? `${url}?${paramStr}` : url
}

function showToast(message = '', duration = 0) {
  if (!message) return
  prompt.showToast({
    message: message,
    duration
  })
}
function log(logStr,chunkSize = 80){
  console.log("--begin--")
  for (var i = 0; i < logStr.length; i += chunkSize) {
    console.log(logStr.substring(i, i + chunkSize))
  }
  console.log("--end--")
}

export default {
  showToast,
  queryString,
  log
}
